<template>
  <div class="panel-body">
    <div>
      <h2>Home组件内容</h2>
      <div>
        <ul class="nav nav-tabs">
          <li>
            <router-link class="list-group-item" active-class="active" to="/home/news">News</router-link>
          </li>
          <li>
            <router-link class="list-group-item" active-class="active" to="/home/message">Message</router-link>
          </li>
        </ul>
        <!-- 
          keep-alive 保持活跃
          可以使路由组件在被切换掉的时候不会销毁，通过包裹router-view组件标签
          include属性可以设置指定哪个组件路由不被销毁，include指定的是组件名，所以一般是大写的开头
          即.vue文件中script标签内所指定的那个name属性
          如果不设置include指定哪个组件路由，那么所有展示的组件路由都将设定为不被销毁

          1. 缓存包裹住的路由视图中指定单个路由组件：<kepp-alive include="组件name"></kepp-alive>
          2. 缓存包裹住的路由视图中指定多个路由组件：<kepp-alive :include="["组件a_name","组件b_name"]"></kepp-alive>
          3. 缓存包裹住的路由视图所展示的所有路由：<keep-alive></keep-alive>
         -->
        <keep-alive include="News">
          <router-view></router-view>
        </keep-alive>
      </div>
    </div>
  </div>
</template>

<script>
import Message from "./Message";
import News from "./News";
export default {
    name:"Home",
    components:{
      Message,
      News
    },
    mounted() {
      // 当再次回到该路由，则会再次挂载！
      // console.log("Home路由挂载完毕");
    },
    beforeDestroy() {
      // 路由在被切换掉后实际上默认被销毁了！
      // console.log("Home路由被销毁")
    },
}
</script>